﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Games;

namespace Cards
{
    public class ManageCards
    {
        public static Card[] arrayCard;

        public ManageCards()
        { }

        public static void createCards(GameTypes objGT)
        {
            arrayCard = new Card[36];
            if (objGT == GameTypes.BaCay)
                for (int i = 0; i <= 8; i++)
                {
                    foreach (PropertyCards oCard in Enum.GetValues(typeof(PropertyCards)))
                    {
                        arrayCard[i * 4 + (int)oCard] = new Card();
                        arrayCard[i * 4 + (int)oCard].BDistribute = false;
                        arrayCard[i * 4 + (int)oCard].INumber = i + 1;
                        arrayCard[i * 4 + (int)oCard].UPCard = oCard;
                    }
                }
        }

        public static Card DistributeCards(GameTypes objGT)
        {
            bool bDistributed = false;
            Random objR = new Random();
            int Count = 0;
            while (!bDistributed)
            {
                if (Count >= arrayCard.Length)
                    return null;
                if (objGT == GameTypes.BaCay)
                {
                    int i = objR.Next(35);
                    if (arrayCard[i].BDistribute == false)
                    {
                        arrayCard[i].BDistribute = true;
                        bDistributed = true;
                        return arrayCard[i];
                    }
                }
                else return null;
                Count++;
            }
            return null;
        }
    }
}
